using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using static GiftManager;
using Spine.Unity;
public class Teacher : MonoBehaviour
{

    private string[] talkOptions = new string[] {
        "谁来回答？没人举手我点名了！",
        "你们是我带过最差的一届！",
        "整栋楼就咱班最吵！",
        "我在办公室就听见你们的声音了！",
        "讲完这题就下课。",
        "不想听可以睡觉，别影响别人！",
        "上课不要玩手机，影响学习！",
        "这道题讲过多少遍了，还不会？",
        "体育老师请假了，这节上数学。",
        "耽误大家一分钟……",
        "这道题我讲过多少遍了？",
        "带作业的举手——没带的站起来！",
        "你们考不好，我比你们还难受。",
        "现在恨我，以后你们会感谢我。",
        "你讲还是我讲？要不你上来讲？",
        "Listen to me carefully！",
        "小球从光滑斜面滑下…",
        "这段话表达了作者怎样的思想感情？",
        "这道题是送分题，你们怎么都不会？",
        "毕业了你们就自由了",
        "毕业不是终点，是另一段人生的起点。",
        "加油，同学们！",
    };
    private string talk;
    public Image teacherImageTalk;
    public Text teacherTextTalk;

    public SkeletonGraphic skeletonGraphic;
    // Start is called before the first frame update
    void Start()
    {
        StringEventSystem.Global.Register(EventID.PlayGiftAnimation, (object[] _params) =>
            {
                if ((AnimaName)_params[0] == AnimaName.TeacherSpeak)
                {
                    SetTeacherImageTalk();
                }
            }).UnRegisterWhenGameObjectDestroyed(gameObject);


    }

    // Update is called once per frame
    void Update()
    {

    }
    public void SetTeacherImageTalk()
    {
        // 播放说话动画
        skeletonGraphic.AnimationState.SetAnimation(0, "shuohua", false);
        talk = talkOptions[UnityEngine.Random.Range(0, talkOptions.Length)];
        Debug.Log($"Selected talk option: {talk}");
        teacherTextTalk.text = talk;
        teacherImageTalk.gameObject.SetActive(true);
        teacherTextTalk.gameObject.SetActive(true);
        Invoke("HideTeacherImageTalk", 3f);
    }
    //隐藏说话动画
    private void HideTeacherImageTalk()
    {
        teacherImageTalk.gameObject.SetActive(false);
        teacherTextTalk.gameObject.SetActive(false);
        skeletonGraphic.AnimationState.SetAnimation(0, "daiji", true);
    }
}
